<?php


require '../vendor/autoload.php';


use Aws\DynamoDb\Exception\DynamoDbException;
use Aws\DynamoDb\Marshaler;

$sdk = new Aws\Sdk([
    'region'   => 'us-west-2',
    'version'  => 'latest',
    'credentials' => [
        'key' => 'AKIA4SBKFCJAXUOUXUN2',
        'secret' => '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',
    ],
]);

$dynamodb = $sdk->createDynamoDb();
$marshaler = new Marshaler();
$tableName='group';
$params = [
    'RequestItems' => [
        $tableName => [
            [
                'DeleteRequest' => [
                    'Key' =>$marshaler->marshalItem(['group_id' => 3,'user_id' => 177013573]),//传入分区键和排序键
                ],

            ],
            [
                'DeleteRequest' => [
                    'Key' =>$marshaler->marshalItem(['group_id' => 3,'user_id' =>46533241 ]),//传入分区键和排序键
                ],
            ]
        ]
    ]
];


try {
    $result = $dynamodb->batchWriteItem($params);
    var_dump($result);

} catch (DynamoDbException $e) {
    echo "Unable to batch write item:\n";
    echo $e->getMessage() . "\n";
}